<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="utf-8" />
		<title>forget</title>
		<link rel="stylesheet" type="text/css" href="../css/login.css"/>
		<link rel="stylesheet" type="text/css" href="../css/public.css"/>
		<link rel="stylesheet" type="text/css" href="../css/proList.css" />
		<link rel="stylesheet" type="text/css" href="../css/forget.css" />
	</head>
	<body>
		<!----------------------------------------order------------------>
		<div class="order cart">
			<!-----------------logo------------------->
			<div class="logo">
				<h1 class="wrapper clearfix">
					<a href="index.html"><img class="fl" src="../img/temp/logo1.jpg"></a>
				</h1>
			</div>
			<div class="forCon">
				<p>安全设置-找回密码</p>
				<ul>
					<li class="on"><span>01/</span>输入登录名</li>
					<li><span>02/</span>验证信息</li>
					<li><span>03/</span>重置密码</li>
				</ul>
				<div class="formCon">
					<!--步骤1-->
					<form action="#" method="post" class="one">
						<input type="text" class="phoNum" placeholder="手机号"><label>请输入手机号</label>
						<div class="getCode">获取验证码</div>
						<br />
						<input type="text" class="yzmNum" placeholder="验证码"><br />
						<!--<img src="../img/temp/code.jpg"><br>-->
						<input type="button" value="下一步" class="next">
					</form>
					<!--步骤2-->
					<form action="#" method="post" class="two">
						<p>手机号码：<span></span></p>
						<p class="tip">验证码已发成功接受，请继续完成验证</p>
						<input type="button" value="去重置密码" class="next1">
					</form>
					<!--步骤3-->
					<form action="#" method="post" class="three">
						<label>新密码：</label><input type="text" class="newPsd" placeholder="新密码"><br />
						<label>确认密码：</label><input type="text" class="aginPsd" placeholder="再次输入新密码"><br />
						<!--<label>确认密码：</label><input class="aginPsd" placeholder="再次输入新密码"><br/>-->
						<input type="button" class="sureLogin" value="完成">
					</form>
				</div>
			</div>
		</div>
		<div class="dialogShow">
			<p>温馨提示</p>
			<span>报错</span>
			<div class="closoeSure">确定</div>
		</div>
		
		<script src="../js/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
		<!--<script src="../js/public.js" type="text/javascript" charset="utf-8"></script>-->
		<script src="../js/pro.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/jquery-1.11.1.min.js?time=2017072509"></script>
		<script type="text/javascript">
            $(function() {
                var host = 'https://api.0-fashion.com';

                var phoNum, yzmNum, newPsd, aginPsd;
                $(".getCode").click(function() {
                    $(".getCode").css("background-color", '#901C1C').css('color', '#988E8E');
                    setTimeout(function() {
                        $(".getCode").css("background-color", 'rgb(232,91,91)').css('color', '#fff');
                    }, 300);
                })
                var countdown = 60;

                function settime() {
                    if(countdown == 0) {
                        $(".getCode").html('获取验证码').css("background", "rgb(232,91,91)").css("color", '#fff').css("z-index", '1');
                    } else {
                        $(".getCode").html('重新发送(' + countdown + ')').css("background", "#000").css("color", 'darkgrey').css("z-index", '-1');
                        countdown--;
                    }
                    setTimeout(function() {
                        settime();
                    }, 1000);
                }
                $(".getCode").click(function() {
                    phoNum = $(".phoNum").val();
                    $.ajax({
                        type: "post",
                        url: host + "/api/message/verifycode/get",
                        data: {
                            PhoneNumber: phoNum,
                            VerifyCodeType: 1
                        },
                        success: function(data) {
                            if(data.ResultType == 3) {
                                settime();
                                showDiag("验证码已发送");
                            } else {
                                showDiag(data.Message);
                            }
                        }
                    });
                })
                $(".backLogon").click(function() {
                    window.location.href = 'login.html';
                })
                $(".sureLogin").click(function() {
                    yzmNum = $(".yzmNum").val();
                    newPsd = $(".newPsd").val();
                    aginPsd = $(".aginPsd").val();
                    if(newPsd != aginPsd) {
                        showDiag('两次密码不一致');
                    } else {
                        $.ajax({
                            type: "post",
                            url: host + "/api/members/member/updatepassword",
                            data: {
                                PhoneNumber: phoNum,
                                PassWord: newPsd,
                                VerifyCode: yzmNum,
                            },
                            success: function(data) {
                                if(data.ResultType == 3) {
                                    $.ajax({
                                        type: "post",
                                        url: host + '/api/members/member/login',
                                        data: {
                                            PhoneNumber: phoNum,
                                            PassWord: newPsd
                                        },
                                        success: function(data) {
                                            if(data.ResultType == 3) {
                                                localStorage.MemberId = data.Data.MemberId;
                                                localStorage.u_num = data.Data.U_Num;
                                                window.location.href = 'index.html';
                                            } else {
                                                showDiag(data.Message);
                                            }
                                        }
                                    });
                                } else {
                                    showDiag(data.Message);
                                }
                            }
                        });
                    }
                })

                function showDiag(msg) {
                    $(".dialogShow").show();
                    $(".dialogShow span").html(msg);
                }
                $(".closoeSure").click(function() {
                    $(".dialogShow").hide();
                });
            });
		</script>

	</body>
</html>
